library all_websocket;

import 'src/all_websockt_imp.dart' if (dart.library.html) 'src/all_websockt_web_imp.dart' as socket;

typedef OnMessage = Function(dynamic message);
typedef OnError = Function(dynamic error);
typedef OnClose = Function();


///通用 WebSocket 接口
///解决 Web 和 app 和 dosktop 的兼容
abstract class WebSocket {
  factory WebSocket() => socket.WebSocket();

  Future<WebSocket> connect(String url, {Iterable<String> protocols});

  set onMessage(OnMessage value);

  set onError(OnError value);

  set onClose(OnClose value);

  void close() {}

  void add(dynamic encode) {}

}
